//
//  UITableViewCellFixed.m
//  SplitForce
//
//  Created by Ron Hess on 7/17/10.
//  Copyright 2010 Salesforce.com. All rights reserved.
//

#import "UITableViewCellFixed.h"


@implementation UITableViewCellFixed
@synthesize textLabel2, detailTextLabel2,editText;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

	self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self != nil) {
		self.textLabel2 = [[UILabel alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 200.0f, 43.0f)] ;
		
	//	[self addSubview: self.textLabel2];
		self.textLabel2.text = nil;
		
		detailTextLabel2 = [[UILabel alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 200.0f, 43.0f)];
		
	//	[self addSubview: detailTextLabel2];
		self.detailTextLabel2.text	= nil;
		
				
	}
	return self;
}

- (void)setHasTwoCols:(BOOL)inp {
    if ( inp ) {
		[self addSubview: textLabel2];
		[self addSubview: detailTextLabel2];
	}
}

/* layout the textLabel a bit wider for long labels 
 * TODO wrap ?
 */
#define COL_TWO_PERCENT 0.35f
#define LABELCOL_ADDEDWIDTH 0 /*40.0f*/

- (void) layoutSubviews {
	[super layoutSubviews];
	CGRect up = super.frame;
	
	//NSLog(@"layoutSubviews super is h:%f w:%f",up.size.height,up.size.width);

//	self.textLabel.adjustsFontSizeToFitWidth = YES;
	self.textLabel.numberOfLines = 2;

	self.textLabel.frame = CGRectMake(self.textLabel.frame.origin.x, 
                                      self.textLabel.frame.origin.y, 
                                      self.textLabel.frame.size.width + LABELCOL_ADDEDWIDTH, 
                                      self.textLabel.frame.size.height);
	
	self.detailTextLabel.numberOfLines = 2;
	self.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
	self.detailTextLabel.adjustsFontSizeToFitWidth = YES;
	self.detailTextLabel.frame = CGRectMake(self.detailTextLabel.frame.origin.x+ LABELCOL_ADDEDWIDTH, 
											self.detailTextLabel.frame.origin.y ,
											self.detailTextLabel.frame.size.width ,
											//230, 
											self.detailTextLabel.frame.size.height);
	
	UILabel *l = self.textLabel;

	self.textLabel2.numberOfLines = 2;
	self.textLabel2.font = l.font;
	self.textLabel2.textColor = l.textColor;
	self.textLabel2.textAlignment = l.textAlignment;
	self.textLabel2.highlightedTextColor = l.highlightedTextColor;
	self.textLabel2.lineBreakMode = UILineBreakModeWordWrap;

	self.textLabel2.frame = CGRectMake(up.size.width * (COL_TWO_PERCENT),
									   self.textLabel.frame.origin.y, 
									   self.textLabel.frame.size.width , 
									   self.textLabel.frame.size.height);
	
	l = self.detailTextLabel;
	
	self.detailTextLabel2.font = l.font;
	self.detailTextLabel2.textColor = l.textColor;
	self.detailTextLabel2.textAlignment = l.textAlignment;
	self.detailTextLabel2.numberOfLines = 2;
	self.detailTextLabel2.highlightedTextColor = l.highlightedTextColor;
	self.detailTextLabel2.lineBreakMode = UILineBreakModeWordWrap;

	self.detailTextLabel2.frame = CGRectMake(up.size.width * (COL_TWO_PERCENT)+ 
											  self.textLabel2.frame.size.width +5.0,
											 self.detailTextLabel2.frame.origin.y ,
											 self.detailTextLabel2.frame.size.width , 
											 self.detailTextLabel2.frame.size.height);
		
	
	
}

@end
